home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 11
/
CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso
/
s
/
tableimport.pprx
< prev
next >
Wrap
Text File
|
1993-01-28
|
3KB
|
133 lines
/*
@BTableImport @P@ICopyright Gold Disk Inc. January, 1992
This Genie will read a data file and produce a table. Values must be between quotes and comma or tab separated with no extra spaces between entries.
(Ex: "Value 1","Value 2","Value 3"...)
*/
numeric digits 8
cr = '0a'x
address command
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
units = ppm_GetUnits()
if units = 3 then
call ppm_SetUnits(1)
signal on halt
signal on break_c
signal on break_e
signal on break_d
box = ppm_ClickOnBox("Click on box in which to import table.")
if box = 0 then
do
call ppm_Inform(1, "No box selected",)
call ppm_ClearStatus()
exit
end
/* extract box attributes */
boxsize = ppm_GetBoxSize(box)
boxpos = ppm_GetBoxPosition(box)
if ppm_Inform(2, "Delete original box?",) = 1 then call ppm_DeleteBox(box)
filename = ppm_GetFileName("Select file to be imported", "","")
if filename = '' then exit_msg()
if ~open(file, filename, "r") then exit_msg("Unable to open file: "filename)
line = readln(file)
/* Determine field delimiters */
if pos('","', line) ~= 0 then delimiter = '","'
else if pos('09'x, line) ~= 0 then delimiter = "'09'x"
else exit_msg("File must be either comma delimited or tab delimited.")
/* determine number of columns */
cols = 1
do while line ~ = ''
interpret "parse var line matrix.1.cols "delimiter" line"
if delimiter = '","' then matrix.1.cols = strip(matrix.1.cols, b, '"')
cols = cols + 1
end
cols = cols - 1
rows = 1
do while ~eof(file)
line = readln(file)
if line = '' then iterate
rows = rows + 1
do col = 1 to cols
interpret "parse var line matrix."rows"."col" "delimiter" line"
if delimiter = '","' then matrix.rows.col = strip(matrix.rows.col, b, '"')
if line = '' then leave
end
end
selection = "Right Justify Numbers"cr"Make Grid Lines"
selection = upper(ppm_SelectFromList("Select Options", 30, 5, 1, selection))
if selection = '' then exit_msg()
if pos(GRID, selection) ~= 0 then grid = 1
else grid = 0
if pos(RIGHT, selection) ~= 0 then right = 1
else right = 0
call ppm_SetSize(12)
boxwidth = word(boxsize, 1) / cols
boxheight = word(boxsize, 2) / rows
boxleft = word(boxpos, 1)
boxtop = word(boxpos, 2)
left = boxleft
top = boxtop
do row = 1 to rows
do col = 1 to cols
call ppm_ShowStatus("Working on row:"row" column:"col)
box = ppm_CreateBox(left, top, boxwidth, boxheight, 0,)
left = left + boxwidth
call ppm_SetBoxMargins(box, .1, .1, .1, .1)
if grid then
do
call ppm_SetBoxFrame(box, 1)
call ppm_SetBoxFrameData(box, "black", "black", .5, 1, 0)
end
if matrix.row.col = "" then matrix.row.col = " "
if right & datatype(matrix.row.col) = 'NUM' then
call ppm_TextIntoBox(box, ""strip(matrix.row.col))
else
call ppm_TextIntoBox(box, ""strip(matrix.row.col))
end
left = boxleft
top = top + boxheight
end
exit_msg("Done")
break_d:
break_e:
break_c:
halt:
call exit_msg("User aborted Genie!")
exit_msg: procedure expose units
do
parse arg message
call ppm_ClearStatus()
if message ~= '' then
call ppm_Inform(1, message,)
call ppm_SetUnits(units)
call ppm_AutoUpdate(1)
exit
end